<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class home extends CI_Controller {
	
	function __construct()
	{
		parent::__construct();		
		$this->load->model('home_model','home');
		$this->load->model('news_model','news');
		$this->load->config('config_gioithieu') ;
	}
	
	function index()
	{
		$data['title'] = "" ;
		$data['listcat'] = $this->home->get_item_cat();
		$data['list_bnright'] = $this->home->get_bnright();//trit($data['list_bnright']);
		$data['list_bottom'] = $this->home->get_bnbottom();
		$data['listnew'] = $this->news->getNews(3);//trit($data['listnew']);
		$this->load->view('home',$data) ;
	}
	
	function search()
	{
		$data['title'] = 'Tìm kiếm' ;
		$data['listcat'] = $this->home->get_item_cat();
		$keyword = trim($this->input->post('keyword'));
		$data['start'] = (int) $this->uri->segment(4) ; 
		$config['base_url'] = base_url().'home/search/'.(int)$this->uri->segment(3);  
		$data['num'] = $this->home->count_search($keyword);
		$config['total_rows'] = $data['num'];
		$config['per_page'] = 6;
		$config['uri_segment'] = 4;
		$config['num_links'] = 3 ;
		$this->pagination->initialize($config);   
		$data['pagination'] = $this->pagination->create_links();
		
		$data['list'] = $this->home->get_search($keyword, $config['per_page'],$data['start']);//trit($data['list']);
		$this->load->view('search', $data);
	}
	
	function getBannerId()
	{
		$bannerId = $this->uri->segment(3);
		$data['list'] = $this->home->showBanneCat($bannerId);//trit($data['list']);
		$this->load->view('showbanner',$data);
	}
	
}
	

/* End of file welcome.php */
/* Location: ./system/application/controllers/welcome.php */